package com.itheima.controller;

import com.itheima.pojo.Result;
import com.itheima.pojo.Task;
import com.itheima.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/task")
public class TaskController {
    @Autowired
    private TaskService taskService;

    @RequestMapping("/sendTask")
    public Result sendTask(@RequestBody Task task) {
        taskService.addTask(task);
        return new Result();
    }

    @RequestMapping("/getTaskList")
    public Result getTaskList(@RequestBody Task task) {

        return Result.success(taskService.getTaskList(task));
    }
    @RequestMapping("/submit")
    public Result submitTask(@RequestBody Task task) {
        taskService.submit(task);
        return Result.success();
    }
}
